home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / string.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  3.9 KB  |  79 lines  |  [TEXT/MPS ]

  1. (* String operations *)
  2.  
  3. value string_length : string -> int = 1 "string_length"
  4.         (* Return the length (number of characters) of the given string. *)
  5. ;;
  6. value nth_char : string -> int -> char
  7.         (* [nth_char s n] returns character number [n] in string [s].
  8.            The first character is character number 0.
  9.            The last character is character number [string_length s - 1].
  10.            Raise [Invalid_argument "nth_char"] if [n] is ouside the range
  11.            0 -- [(string_length s - 1)]. *)
  12.   and set_nth_char : string -> int -> char -> unit
  13.         (* [set_nth_char s n c] modifies string [s] in place,
  14.            replacing the character number [n] by [c].
  15.            Raise [Invalid_argument "set_nth_char"] if [n] is ouside the range
  16.            0 to [(string_length s - 1)]. *)
  17. ;;
  18. value prefix ^ : string -> string -> string
  19.         (* [s1 ^ s2] returns a fresh string containing the concatenation of
  20.            the strings [s1] and [s2]. *)
  21.   and sub_string : string -> int -> int -> string
  22.         (* [sub_string s start len] returns a fresh string of length [len],
  23.            containing the characters number [start] to [start + len - 1]
  24.            of string [s].
  25.            Raise [Invalid_argument "sub_string"] if [start] and [len] do not
  26.            designate a valid substring of [s]; that is, if [start < 0],
  27.            or [len < 0], or [start + len > string_length s]. *)
  28. ;;
  29. value create_string : int -> string
  30.         (* [create_string n] returns a fresh string of length [n].
  31.            The string initially contains arbitrary characters. *)
  32.   and make_string : int -> char -> string
  33.         (* [make_string n c] returns a fresh string of length [n],
  34.            filled with the character [c]. *)
  35. ;;
  36. value fill_string : string -> int -> int -> char -> unit
  37.         (* [fill_string s start len c] modifies string [s] in place,
  38.            replacing the characters number [start] to [start + len - 1]
  39.            by [c].
  40.            Raise [Invalid_argument "fill_string"] if [start] and [len] do not
  41.            designate a valid substring of [s]. *)
  42.   and blit_string : string -> int -> string -> int -> int -> unit
  43.         (* [blit_string s1 o1 s2 o2 len] copies [len] characters
  44.            from string [s1], starting at character number [o1], to string [s2],
  45.            starting at character number [o2]. It works correctly even if
  46.            [s1] and [s2] are the same string,
  47.            and the source and destination chunks overlap.
  48.            Raise [Invalid_argument "blit_string"] if [o1] and [len] do not
  49.            designate a valid substring of [s1], or if [o2] and [len] do not
  50.            designate a valid substring of [s2]. *)
  51.   and replace_string : string -> string -> int -> unit
  52.         (* [replace_string dest src start] copies all characters from the 
  53.            string [src] into the string [dst], starting at
  54.            character number [start] in [dst].
  55.            Raise [Invalid_argument "replace_string"] if copying would overflow
  56.            string [dest]. *)
  57. ;;
  58. value eq_string : string -> string -> bool = 2 "=string"
  59.   and neq_string : string -> string -> bool = 2 "<>string"
  60.   and le_string : string -> string -> bool = 2 "<=string"
  61.   and lt_string : string -> string -> bool = 2 "<string"
  62.   and ge_string : string -> string -> bool = 2 ">=string"
  63.   and gt_string : string -> string -> bool = 2 ">string"
  64.         (* Comparison functions (lexicographic ordering) between strings. *)
  65. ;;
  66. value compare_strings : string -> string -> int = 2 "compare_strings"
  67.         (* General comparison between strings.
  68.        [compare_strings s1 s2] returns 0 if [s1] and [s2] are equal,
  69.        or else -2 if [s1] is a prefix of [s2],
  70.        or 2 if [s2] is a prefix of [s1],
  71.        or else -1 if [s1] is lexicographically before [s2],
  72.        or 1 if [s2] is lexicographically before [s1]. *)
  73. ;;
  74. value string_for_read : string -> string
  75.         (* Return a copy of the argument, with special characters represented
  76.            by escape sequences, following the lexical conventions of
  77.            Caml Light. *)
  78. ;;
  79.